﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using System.Web;
using Hades.StaticContentManager;
/// <summary>
/// Descripción breve de Persistance
/// </summary>
public static class Persistance
{
    #region Variables
    //TODO: HACER ESTATICA LA CLASE

    private static string _domain; 

    #endregion
	
    public static void LoadFiles()
    {
       _domain = HttpContext.Current.Request.Url.AbsoluteUri;

        StaticContentManager content = new StaticContentManager();
        Dictionary<string, string> xmlData = content.GetAll(_domain);
        //Graba a memoria de aplicacion
        HttpContext.Current.Application.Add("DicXML", xmlData);
    }

    public static string GetDataByKey(string key)
    {
        try
        {
            //Lee de memoria de aplicacion 
            Dictionary<string, string> dicXML = (Dictionary<string, string>)HttpContext.Current.Application["DicXML"];

            return dicXML.Where(x => x.Key == key).First().Value;
        }
        catch (Exception e)
        {
            
            throw;
        }
       
    }
}